package com.xin.utils
{
/**
 * @author daichangxin
 */
public class ColorUtils
{
	/**
	 * 根据argb获取颜色
	 */
	public static function getColor(r:uint, g:uint, b:uint, a:uint = 0):uint
	{
		return a << 24 | r << 16 | g << 8 | b;
	}
	
	/**
	 * 随机生成颜色
	 */
	public static function getRandomColor():uint
	{
		return getColor(0xFF * Math.random(), 0xFF * Math.random(), 0xFF * Math.random(), 0xFF * Math.random());
	}
	
	/**
	 * 根据颜色返回argb值：return {"a":a, "r":r, "g":g, "b":b};
	 */
	public static function getRGB(color:uint):Object
	{
		var a:uint = color >> 24;
		var r:uint = color >> 16 & 0xFF;
		var g:uint = color >> 8 & 0xFF;
		var b:uint = color & 0xFF;
		return {"a":a, "r":r, "g":g, "b":b};
	}
}
}
